package ProxyDemoCodes;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * <pre>
 * Created with IntelliJ IDEA.
 * User: zhengzhi
 * Date: 2017/11/24
 * Time: 14:55
 * To change this template use File | Settings | File Templates.
 * </pre>
 *
 * 代理类
 */
public class ProxySubject implements InvocationHandler {

    private Object sub;

    //构造函数
    public ProxySubject(Object object){
        this.sub = object;
    }


    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("before calling Method : " + method);
        method.invoke(sub,args);
        System.out.println("after calling Method " + method);
        return null;
    }
}
